﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

using System.Reflection;
using System.Windows.Threading;

namespace PermDoc
{
    public partial class MainPage : UserControl
    {

        #region Members
        private bool IsInit = false;
        protected static DispatcherTimer _timer_idle = new DispatcherTimer();
        private Uri _WelcomeUri = new Uri(@"/Welcome.xaml", UriKind.Relative);
        #endregion

        #region Constructors
        public MainPage()
        {
            InitializeComponent();
            Assembly assembly = Assembly.GetExecutingAssembly();
            String version = assembly.FullName.Split(',')[1];
            oCaption.Content = "Первичные документы. ( Версия модуля: " + version + " ) ; build info";
#if DEBUG
            oCaption.Content += " : Debug ; Idle max: " + App._idleMax + " sec.";
#else
            oCaption.Content += " : Release ; Idle max: " + App._idleMax + " sec.";
#endif
        }
        #endregion

        #region Page Events
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            App.IdleEmpty();
            _timer_idle.Tick += new EventHandler(myTimer_Idle);
            _timer_idle.Interval = new TimeSpan(0, 0, 1);
            _timer_idle.Start();
            IsInit = true;
        }
        private void UserControl_Unloaded(object sender, RoutedEventArgs e)
        {
            _timer_idle.Stop();
            IsInit = false;
        }
        private void UserControl_MouseMove(object sender, MouseEventArgs e)
        {
            App.IdleEmpty();
        }
        private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            App.IdleEmpty();
        }
        private void UserControl_MouseRightButtonUp(object sender, MouseButtonEventArgs e)
        {
            App.IdleEmpty();
        }
        private void UserControl_MouseWheel(object sender, MouseWheelEventArgs e)
        {
            App.IdleEmpty();
        }
        private void UserControl_KeyUp(object sender, KeyEventArgs e)
        {
            App.IdleEmpty();
        }
        void myTimer_Idle(object sender, EventArgs e)
        {
            if (App.Idle > App._idleMax)
            {
            }
        }
        #endregion        
        
    }
}
